<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
	</head>

	<body>
		<p>测试视图切换的事件</p>
		<p>打开
			<a href="page1.html" target="_blank">page1</a>和
			<a href="page2.html" target="_blank">page2</a>,然后在两者之间切换，查看标题</p>
		<script type="text/javascript">
			var normal_title = document.title;
			document.addEventListener('visibilitychange',e => {
				if(document.visibilityState === 'hidden') {
					document.title = '隐藏的标题';
				} else if(document.visibilityState==='visible'){
					document.title = normal_title;
				}
			})
		</script>
	</body>

</html>